<%-- 
    Document   : list
    Created on : 2018-11-6, 10:08:55
    Author     : SakuraSora
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
   pageContext.setAttribute("contextPath", request.getContextPath());
%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>用户列表</title>
        <script>
            function del(id) {
                if(confirm("是否真的要删除 id 为" + id + "的用户")) {
                    location.href = "${contextPath}/user/delete.htm?id="+id;
                }        
            }
        </script>
    </head>
    <body>
        <h1>用户列表</h1>
        <c:if test="${empty list}">
            <h2>当前表没有数据</h2>
        </c:if>
        <c:if test="${not empty list}">
            <table border="1"><!-- <table style="border:solid thick">-->
                <tr>
                    <th>NO.</th>
                    <th>用户名</th>
                    <th>密码</th>
                    <th>操作</th>
                </tr>
                <c:forEach items="${list}" var="user" varStatus="status">
                    <tr>
                        <td>${status.index+1}</td> <!-- 从0+1开始-->
                        <td>${user.name}</td>
                        <td>${user.password}</td>
                        <td>
                            <a href="javascript:del(${user.id})">删除</a>
                        </td>
                    </tr>
                </c:forEach>
            </table>
        </c:if>
    </body>
</html>
